package com.iplant.ams.service.po.ams.fxt;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.ams.service.basicenum.ams.fxt.AMSMeasureType;
import com.iplant.ams.service.po.ams.asset.AMSAssetInfo;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.basic.service.basicenum.bms.BMSFunctionType;

import java.io.Serializable;

@DBBasePO(TableName = "dms_measure_ledger", Name = false, Active = false, Code = false,
        Schemas = DBSchemas.AMS, CheckName = {"AssetInfoID"}, CodeAuto = true, CodePrefix = "DFL-{yyMM}-")
public class DMSMeasureLedger extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;


    @DBCondition
    @DBField
    public int AssetInfoID = 0;

    @DBCondition
    @DBField
    public int MeasureToolID = 0;


    @DBCondition(CompareType = DBCondition.DBCompareType.like)

    @DBJoin(name = "Name", tableName = "ams_asset_list", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "AssetInfoID")
    public String Name = "";


    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "ams_asset_list", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "AssetInfoID")
    public String Code = "";

    @DBCondition
    @DBJoin(name = "Active", tableName = "ams_asset_list", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "AssetInfoID")
    public int Active = 0;

    /**
     * 采集编号
     **/
    @DBCondition
    @DBField
    public String AssetNo = "";

    @DBCondition
    @DBJoin(name = "StandardModelID", tableName = "ams_measuretool", tableAsName = "f1", Schemas = DBSchemas.AMS,
            MainTableField = "MeasureToolID")
    public int StandardModelID = 0;//资产标准型号ID

    /**
     * 量具类型
     */
    @DBCondition
    @DBJoin(name = "MeasureType", tableName = "ams_measuretool", tableAsName = "f1", Schemas = DBSchemas.AMS,
            MainTableField = "MeasureToolID")
    public int MeasureType = 0;

    /**
     * 量具类型文本
     */
    public String MeasureTypeText = "";


    @DBField
    public double MinRange = 0.0;//最小量程
    @DBField
    public double MaxRange = 0.0;//最大量程
    public String RangeText = "";//量程范围

    @DBField
    public int UnitID = 0;//单位ID
    @DBJoin(name = "Name", tableName = "mss_unit", tableAsName = "unit1", Schemas = DBSchemas.Basic,
            MainTableField = "UnitID")
    public String UnitText = "";//单位名称
    @DBJoin(name = "Code", tableName = "mss_unit", tableAsName = "unit1", Schemas = DBSchemas.Basic,
            MainTableField = "UnitID")
    public String UnitCode = "";//单位编码
    @DBField
    public double MinError = 0.0;//最小误差
    @DBField
    public double MaxError = 0.0;//最大误差

    public String ErrorText = "";//误差描述


    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "ams_asset_standard_model", tableAsName = "a2", JoinIndex = 2, Schemas = DBSchemas.AMS,
            ConditionalJoin = "f1.StandardModelID=a2.ID")
    public String StandardModelName = "";


    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "ams_asset_standard_model", tableAsName = "a2", JoinIndex = 2, Schemas = DBSchemas.AMS,
            ConditionalJoin = "f1.StandardModelID=a2.ID")
    public String StandardModelCode = "";


    @DBField
    public int Status = 0;

    @DBField
    public String Position = "";

    /**
     * 使用班组
     */
    @DBCondition
    @DBField
    public int ClassInfoID = 0;


    /**
     * 班组对应部门ID（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "DepartmentID", tableName = "bms_classinfo", tableAsName = "f2", Schemas = DBSchemas.Basic,
            MainTableField = "ClassInfoID")
    public int DepartmentID = 0;

    /**
     * 班组名称（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "Name", tableName = "bms_department", tableAsName = "d1", Schemas = DBSchemas.Basic,
            ConditionalJoin = "f2.DepartmentID=d1.ID")
    public String DepartmentName = "";

    /**
     * 班组编码（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "Code", tableName = "bms_department", tableAsName = "d1", Schemas = DBSchemas.Basic,
            ConditionalJoin = "f2.DepartmentID=d1.ID")
    public String DepartmentCode = "";


    /**
     * 班组职能
     */
    @DBCondition
    @DBJoin(name = "FunctionType", tableName = "bms_classinfo", tableAsName = "f2", Schemas = DBSchemas.Basic,
            MainTableField = "ClassInfoID")
    public int FunctionType = 0;

    /**
     * 班组职能（翻译）
     */
    public String FunctionTypeName = "";


    /**
     * 责任人ID
     */
    @DBField
    public int DutyPersonID = 0;
    /**
     * 责任人名称
     */
    @DBJoin(name = "Name", tableName = "mbs_user", tableAsName = "user1", Schemas = DBSchemas.Basic,
            MainTableField = "DutyPersonID")
    public String DutyPersonName = "";

    public DMSMeasureLedger() {
        super();
    }


    public DMSMeasureLedger(AMSAssetInfo wAMSAssetInfo, AMSMeasureTool wAMSMeasureTool) {
        super();

        Name = wAMSAssetInfo.Name;
        AssetNo = wAMSAssetInfo.AssetSN;
        Code = wAMSAssetInfo.Code;
        AssetInfoID = wAMSAssetInfo.ID;
        MeasureToolID = wAMSMeasureTool.ID;
        StandardModelID = wAMSAssetInfo.StandardModelID;
        StandardModelName = wAMSAssetInfo.StandardModelName;
        StandardModelCode = wAMSAssetInfo.StandardModelCode;
        Position = wAMSMeasureTool.Position;
        MeasureType = wAMSMeasureTool.MeasureType;
        Active = wAMSAssetInfo.Active;
    }

    @JsonProperty("AssetInfoID")
    public int getAssetInfoID() {
        return AssetInfoID;
    }

    public void setAssetInfoID(int assetInfoID) {
        AssetInfoID = assetInfoID;
    }

    @JsonProperty("MeasureToolID")
    public int getMeasureToolID() {
        return MeasureToolID;
    }

    public void setMeasureToolID(int measureToolID) {
        MeasureToolID = measureToolID;
    }

    @Override
    @JsonProperty("Name")
    public String getName() {
        return Name;
    }

    @Override
    public void setName(String name) {
        Name = name;
    }


    @JsonProperty("AssetModelID")
    public int getStandardModelID() {
        return StandardModelID;
    }

    public void setStandardModelID(int standardModelID) {
        StandardModelID = standardModelID;
    }

    @JsonProperty("MeasureInfoName")
    public String getStandardModelName() {
        return StandardModelName;
    }

    public void setStandardModelName(String standardModelName) {
        StandardModelName = standardModelName;
    }

    @JsonProperty("MeasureInfoCode")
    public String getStandardModelCode() {
        return StandardModelCode;
    }

    public void setStandardModelCode(String standardModelCode) {
        StandardModelCode = standardModelCode;
    }


    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("ClassInfoID")
    public int getClassInfoID() {
        return ClassInfoID;
    }

    public void setClassInfoID(int classInfoID) {
        ClassInfoID = classInfoID;
    }

    @JsonProperty("DepartmentID")
    public int getDepartmentID() {
        return DepartmentID;
    }

    public void setDepartmentID(int departmentID) {
        DepartmentID = departmentID;
    }

    @JsonProperty("DepartmentName")
    public String getDepartmentName() {
        return DepartmentName;
    }

    public void setDepartmentName(String departmentName) {
        DepartmentName = departmentName;
    }

    @JsonProperty("DepartmentCode")
    public String getDepartmentCode() {
        return DepartmentCode;
    }

    public void setDepartmentCode(String departmentCode) {
        DepartmentCode = departmentCode;
    }

    @JsonProperty("FunctionType")
    public int getFunctionType() {
        return FunctionType;
    }

    public void setFunctionType(int functionType) {
        FunctionType = functionType;
    }

    @JsonProperty("FunctionTypeName")
    public String getFunctionTypeName() {
        FunctionTypeName = BMSFunctionType.getEnumType(FunctionType).getLabel();
        return FunctionTypeName;
    }

    public void setFunctionTypeName(String functionTypeName) {
        FunctionTypeName = functionTypeName;
    }

    @JsonProperty("Position")
    public String getPosition() {
        return Position;
    }

    public void setPosition(String position) {
        Position = position;
    }

    @JsonProperty("DutyPersonID")
    public int getDutyPersonID() {
        return DutyPersonID;
    }

    public void setDutyPersonID(int dutyPersonID) {
        DutyPersonID = dutyPersonID;
    }

    @JsonProperty("DutyPersonName")
    public String getDutyPersonName() {
        return DutyPersonName;
    }

    public void setDutyPersonName(String dutyPersonName) {
        DutyPersonName = dutyPersonName;
    }

    @JsonProperty("MeasureType")
    public int getMeasureType() {
        return MeasureType;
    }

    public void setMeasureType(int frockType) {
        MeasureType = frockType;
    }

    @JsonProperty("MeasureTypeText")
    public String getMeasureTypeText() {
        MeasureTypeText = AMSMeasureType.getEnumType(MeasureType).getLabel();
        return MeasureTypeText;
    }

    public void setMeasureTypeText(String frockTypeText) {
        MeasureTypeText = frockTypeText;
    }

    @JsonProperty("Code")
    @Override
    public String getCode() {
        return Code;
    }

    @Override
    public void setCode(String code) {
        Code = code;
    }

    @JsonProperty("AssetNo")
    public String getAssetNo() {
        return AssetNo;
    }

    public void setAssetNo(String assetNo) {
        AssetNo = assetNo;
    }


    @JsonProperty("MinRange")
    public double getMinRange() {
        return MinRange;
    }

    public void setMinRange(double minRange) {
        MinRange = minRange;
    }

    @JsonProperty("MaxRange")
    public double getMaxRange() {
        return MaxRange;
    }

    public void setMaxRange(double maxRange) {
        MaxRange = maxRange;
    }

    @JsonProperty("RangeText")
    public String getRangeText() {
        return RangeText;
    }

    public void setRangeText(String rangeText) {
        RangeText = rangeText;
    }

    @JsonProperty("UnitID")
    public int getUnitID() {
        return UnitID;
    }

    public void setUnitID(int unitID) {
        UnitID = unitID;
    }

    @JsonProperty("UnitText")
    public String getUnitText() {
        return UnitText;
    }

    public void setUnitText(String unitText) {
        UnitText = unitText;
    }

    @JsonProperty("UnitCode")
    public String getUnitCode() {
        return UnitCode;
    }

    public void setUnitCode(String unitCode) {
        UnitCode = unitCode;
    }

    @JsonProperty("MinError")
    public double getMinError() {
        return MinError;
    }

    public void setMinError(double minError) {
        MinError = minError;
    }

    @JsonProperty("MaxError")
    public double getMaxError() {
        return MaxError;
    }

    public void setMaxError(double maxError) {
        MaxError = maxError;
    }

    @JsonProperty("ErrorText")
    public String getErrorText() {
        return ErrorText;
    }

    public void setErrorText(String errorText) {
        ErrorText = errorText;
    }

    @Override
    @JsonProperty("Active")
    public int getActive() {
        return Active;
    }

    @Override
    public void setActive(int active) {
        Active = active;
    }
}
